package com.medata.service.impl;

import com.medata.dataObject.Account;
import com.medata.repository.AccountRepository;
import com.medata.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：zb
 * @date ：Created in 2019/3/22 0022 15:22
 * @description：
 */
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountRepository accountRepository;

    @Override
    public Account findByUserName(String name) {
        Account account = accountRepository.findByUserName(name);
        return account;
    }

    @Override
    public List<Account> findAll() {
        List<Account> all = accountRepository.findAll();
        return all;
    }

    @Override
    public void delete(Account account) {
        accountRepository.delete(account);
    }

    @Override
    public Page<Account> findAllByPage(Pageable pageable) {
        Page<Account> page = accountRepository.findAll(pageable);
        return page;
    }

    @Override
    public long findCount() {
        long count = accountRepository.count();
        return count;
    }

    @Override
    public void save(Account account) {
        accountRepository.save(account);
    }

    @Override
    public Account getByTelephon(String phone) {
        return accountRepository.getByTelephon(phone);
    }
}
